package com.zhongyu.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhongyu.pojo.Goods;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface GoodsMapper extends BaseMapper<Goods> {
    @Select("select t1.*,t2.id ,t2.* ,t3.id,t3.pro_Name from smbms_goods t1\n" +
            "left  join smbms_goods_type t2 on t1.goods_typeid=t2.id\n" +
            "left  join smbms_provider t3 on t1.provider_id=t3.id  ${ew.customSqlSegment}")
    @ResultMap("goodsRm")
    List<Goods> findAll(Page page , @Param("ew") Wrapper wrapper);

    @Select("select * from smbms_goods where name=#{name} ")
    List<Goods> findByName(String  name);
    @Select("select * from smbms_goods where code=#{code} ")
    List<Goods> findByCode(String  code);
    @Select("select * from smbms_goods where id=#{Id} ")
    Goods  findById(Integer  Id);

    @Select("select * from smbms_goods where provider_id=#{providerId} ")
    List<Goods> findId(Integer  providerId);
}
